package com.hbnu.test.www.net;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class TCP_server04 {
    public static void main(String[] args) {
        try (ServerSocket serverSocket = new ServerSocket(6666);){

            Socket socket = serverSocket.accept();
            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            PrintWriter printWriter = new PrintWriter(new FileWriter(new File("D:\\软件\\tmp")), true);
            PrintWriter out = new PrintWriter(socket.getOutputStream(), true);

            //时间戳
//            DataInputStream dataInputStream = new DataInputStream(socket.getInputStream());
//            long time = dataInputStream.readLong();

            String line = null;
            while((line = in.readLine())!=null){
//                if("over".equalsIgnoreCase(line)){
//                    break;
//                }
                printWriter.println(line);
            }
            out.println("文件上传成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
